import { Module } from '@nestjs/common';
import { IoredisService } from './ioredis.service';
import { IoredisController } from './ioredis.controller';
import { RedisModule } from '@nestjs-modules/ioredis';
import * as config from 'config';

@Module({
  imports: [
    RedisModule.forRoot({
      type: 'single',
      url: `redis://${config.get('redis.host')}:${config.get('redis.port')}`,
      options: {
        username: config.get('redis.username'),
        password: config.get('redis.password'),
        db: config.get('redis.db')
      }
    })
  ],
  controllers: [IoredisController],
  providers: [IoredisService],
  exports: [IoredisService]
})
export class IoredisModule {}
